//
//  LoginViewController.m
//  CPetro
//
//  Created by ggx on 2017/3/8.
//  Copyright © 2017年 高广校. All rights reserved.
//

#import "LoginViewController.h"

#import "LRMoreInputView.h"
#import "BSButtonView.h"

#import "CGBarButtonItem.h"
@interface LoginViewController ()<BSButtonViewDelegate>

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItemTitle = @"登陆";
    
    LRMoreInputView *lrMoreInputView = [[LRMoreInputView alloc]initItemWithFram:CGRectMake(0,0, SCREEN_WIDTH, 100) andData:@[@{@"assistantName":@"用户名",@"assistantPlaceHolder":@"输入账户名"},@{@"assistantName":@"密码",@"assistantPlaceHolder":@"输入密码"}]];
    [self.view addSubview:lrMoreInputView];
    
    //忘记密码
//    CGBarButtonItem *item = [CGBarButtonItem buttonWithTitle:@"忘记密码?" contentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
//    item.frame = CGRectMake(0, CGRectGetMaxY(lrMoreInputView.frame), SCREEN_WIDTH, 20);
//    [item addTarget:self action:@selector(forgetPassWordAction) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:item];
    
    BSButtonView *bsButtonView = [[BSButtonView alloc]initItemWithFram:CGRectMake(0, self.view.bounds.size.height - 50, SCREEN_WIDTH, 40) andData:@[@"登陆"]];
    bsButtonView.delegate = self;
    [self.view addSubview:bsButtonView];
}
#pragma mark - 登陆
-(void)didActionBottomIndex:(NSInteger)index{
    
    for (UIView *subView in self.view.subviews) {
        if ([subView isKindOfClass:[LRMoreInputView class]]) {
            LRMoreInputView *moreView = (LRMoreInputView *)subView;
            for (UIView *subViewSecond in moreView.subviews) {
                if ([subViewSecond isKindOfClass:[LRInputView class]]) {
                    LRInputView *lrInputView = (LRInputView *)subViewSecond;
                    if (lrInputView.tag == 0) {
                        NSLog(@"登陆 = %@--提示文字 == %@",lrInputView.inputText.text,lrInputView.tipName.text);//
                    }else if (lrInputView.tag == 1){
                        NSLog(@"填入的参数 1==%@--提示文字 == %@",lrInputView.inputText.text,lrInputView.tipName.text);//
                    }else if (lrInputView.tag == 2){
                        NSLog(@"填入的参数 2==%@--提示文字 == %@",lrInputView.inputText.text,lrInputView.tipName.text);//
                    }
                }
            }
        }
    }

    
    [self showAnimated:YES title:@"正在登陆" whileExecutingBlock:^CGDataResult *{
        return [Service loadNetWorkingByParameters:@{@"":@"",@"":@""} andBymethodName:@""];
    } completionBlock:^(BOOL b, CGDataResult *r) {
        //保存用户信息
        
        //返回控制器
        POP;
    }];
}
-(void)forgetPassWordAction{
    PushViewControllerName(@"ForgetPwdViewController");
}
-(void)loginToService{
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
